//
//  ViewController.m
//  bse
//
//  Created by 3iRobot2020 on 2021/6/5.
//

#import "ViewController.h"
#import "HWProgress/HWCircleView.h"
#import "DRUpgradingView/DRUpgradingView.h"

@interface ViewController ()
//@property (nonatomic,strong)HWCircleView *progress;
@property (nonatomic,strong)DRUpgradingView *progress;
@property (nonatomic, assign) float      maxDelay;
@end

@implementation ViewController

//- (void)viewDidLoad {
//    [super viewDidLoad];
//    self.view.backgroundColor = [UIColor lightGrayColor];
//    // Do any additional setup after loading the view.
//    self.progress = [[HWCircleView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
//    self.maxDelay = 1.0/(2*60) - 0.001;
//
////    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)];
////    contentView.backgroundColor = [UIColor whiteColor];
////    contentView.layer.cornerRadius = 20;
////    contentView.layer.masksToBounds = YES;
////    [self.view addSubview:contentView];
////
//    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
//    [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
////    UIView *background = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
////    background.layer.cornerRadius = 50;
////    background.layer.borderColor = UIColor.lightGrayColor.CGColor;
////    background.layer.borderWidth = 3;
////    [contentView addSubview:background];
////    [contentView addSubview:self.progress];
//
//    [self.view addSubview:self.progress];
//
//
//}

-(void)viewDidLoad{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor lightGrayColor];
    self.maxDelay = 1.0/(2*60) - 0.001;
    _progress = [[DRUpgradingView alloc] initWithFrame:CGRectMake(100, 100, 300, 400)];
    [self.view addSubview:_progress];
//    DRUpgradingModel *model = [[DRUpgradingModel alloc] initWithProgressDoColor:[UIColor blackColor] progressUndoColor:[UIColor lightGrayColor] lineWidth:3 contentColor:[UIColor whiteColor] contentRadius:20 contentWidth:200 contentHeight:200];
    
    DRUpgradingModel *model = [[DRUpgradingModel alloc] initWithProgressDoColor:[UIColor greenColor] progressUndoColor:[UIColor blueColor] lineWidth:5 contentColor:[UIColor whiteColor] contentRadius:20 contentWidth:300 contentHeight:400];
    _progress.model = model;
    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
        [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
    
}



-(void)timerAction{
    if (self.progress.progress + self.maxDelay >= 0.90 ) {
        self.progress.progress = 0.90;
       
        NSLog(@"超时了");
//        [self removeTimer];
        
    }else {
        self.progress.progress += self.maxDelay;
        NSLog(@"升级进度+ %lf",self.progress.progress);
        
        
        
    }
}
@end
